package risk.control.application.activity;


import android.annotation.SuppressLint;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.lifecycle.LifecycleOwner;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.bumptech.glide.request.target.Target;
import com.otaliastudios.cameraview.PictureResult;

import java.text.SimpleDateFormat;
import java.util.HashMap;

import risk.control.application.R;
import risk.control.application.activity.base.BaseActivity;


public class QueryResultActivity extends BaseActivity {

    private TextView mTvTitle;

    private ImageView mIvIcon;
    private TextView mTvState;
    private TextView mTvSrc;

    @Override
    protected void postData(HashMap<String, String> dataMap) {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_query_result);
        intiView();
        intiData();
        initListener();
    }

    private void intiView() {
        mTvTitle = findViewById(R.id.tv_result_title);

        mIvIcon = findViewById(R.id.iv_icon);
        mTvState = findViewById(R.id.tv_state);
        mTvSrc = findViewById(R.id.tv_src);
    }

    @SuppressLint("SetTextI18n")
    private void intiData() {
        mTvTitle.setText("查询结果");
        //接收数据
        Bundle receivedBundle = getIntent().getExtras();
        if (receivedBundle != null) {
            String riskLevel = receivedBundle.getString("riskLevel");
            String desc = receivedBundle.getString("desc");
            if (riskLevel == null || riskLevel.isEmpty()) {
                mTvState.setText("查询错误");
                loadPic(R.mipmap.high_risk_bg, mIvIcon);
                return;
            }
            switch (riskLevel) {
                case "1":
                    //请求成功
                    mTvState.setText("高风险");
                    mTvSrc.setText(desc);
                    loadPic(R.mipmap.high_risk_bg, mIvIcon);
                    break;

                case "2":
                    //请求成功
                    mTvState.setText("中风险");
                    mTvSrc.setText(desc);
                    loadPic(R.mipmap.medium_risk_bg, mIvIcon);
                    break;

                case "3":
                    //请求成功
                    mTvState.setText("低风险");
                    mTvSrc.setText(desc);
                    loadPic(R.mipmap.no_risk_bg, mIvIcon);
                    break;

            }
        }
    }

    //加载验证码码图片
    private void loadPic(int res, ImageView view) {
        Glide.with(QueryResultActivity.this)//
                .load(res)//
                .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL) // 使用原始尺寸
                .transition(DrawableTransitionOptions.withCrossFade()) // 添加淡入淡出效果
                .into(view);
    }

    private void initListener() {

    }

    @Override
    protected void onResume() {
        super.onResume();

    }

    @Override
    protected void onPause() {
        super.onPause();

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();


    }

}





